package de.hmm.hwip.connection.client;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import android.util.Log;

/**
 * OSGi network service
 * Listen on Socket, wait for connection
 * 
 * @author johannes mendel
 * @version 25.10.2012
 *
 */
public class Activator implements BundleActivator{

	/**
	 * Class identifier to debug
	 */
	final private String TAG = "Activator (conn client)";
	
	/**
	 * receives commands from gui
	 */
	//private IRequest guiservice;
	
	private static BundleContext context;
	
	/**
	 * start the service
	 */
	@Override
	public void start(BundleContext context) throws Exception {
		Log.i(TAG, "=========== de.hmm.hwip.connection.client =========== started ===========");
		    	
		//guiservice = new GuiCommandReceiver();
		/*
        Hashtable<String, Object> params = new Hashtable<String, Object>();
        params.put( org.osgi.framework.Constants.SERVICE_PID, IRequest.class.getName());
        params.put( org.osgi.framework.Constants.SERVICE_DESCRIPTION,"Provides Gui Service");
        context.registerService(IRequest.class.getName(), guiservice, params);
    	*/
       
		SpotServer ss = new SpotServer(context);
		Thread sst = new Thread(ss);
		sst.start();
		
		Activator.context = context;
	}

	@Override
	public void stop(BundleContext context) throws Exception {
		Log.i(TAG, "Socket listener service stoped ...");
	}
	
	public static BundleContext getContext()
	{
		return context;
	}
	
	//closes socket
	public static void closeSocket()
	{
		SpotServer.closeSpot();
	}
	
	public static void getRest(){
		//service.getRest();
	}
}
